$(function(){
	//初始化图片预览框的位置
	var windowW = $(window).width();
	var imageshowW = $("#imageshow").css('width');
	var left = (windowW - parseInt(imageshowW))/2;
	$("#imageshow").css({left : left+'px'});
	$(".thumbimg").click(function (){
		$("#imageshow").css("display","block");
		$("#imageshow img").attr("src",$(this).attr('src'));
	});

	//添加拖拽事件
	var oimageshow = document.getElementById("imageshow");
	drag(oimageshow);
	//关闭预览窗口
	$("#imageshow span").click(function (){
		$("#imageshow").css("display","none");
	});

	//异步删除图片
	$(".delimg").click(function(){
		if(!confirm("确定删除图片？")){
			return false;
		}
		var delPath = CONTROL+"/delImg";
		var iid = $(this).attr("iid");
		$.post(delPath,{iid:iid},function(data){
			if(data['state']==''){
				alert(data['msg']);
				location.reload();
			}else if(data['state']=='er'){
				alert(data['msg']);
			}
		},'json');
	});
});

